package com.shenzhenai.composebasic.components

import androidx.compose.foundation.clickable
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview

/**
 * @author huangzehui
 * @date 2025/9/12 13:24 周五
 * @description
 *
 * State 用法
 * https://www.bilibili.com/video/BV1sS4y1r7Jd?vd_source=e07cc8cc94eb22bd76722071b03cd199&spm_id_from=333.788.player.switch
 */

@Composable
fun StateSample() {

    // 普通方式
//    val count = remember {
//        mutableStateOf(1)
//    }

    // 委托方式
    var count by remember {
        mutableStateOf(1)
    }

    // 解构方式
//    val (value, setValue) = remember {
//        mutableStateOf(1)
//    }

    Text("我今天想叫${count}个小姐姐", modifier = Modifier.clickable {
        count++
    })
}

@Preview
@Composable
fun StateSamplePreview() {
    StateSample()
}
